package com.example.springbootdemo.service;

import com.example.springbootdemo.entity.MallProductSpec;
import com.example.springbootdemo.entity.WecSupplierSpecWithBLOBs;
import com.example.springbootdemo.mapper.MallProductSpecMapper;
import com.example.springbootdemo.mapper.WecSupplierSpecMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Auther: zyb
 * @Date: 2018/11/1 10:27
 * @Description:
 */
@Service("productService")
public class ProductServiceImpl {

    @Autowired(required = false)
    private WecSupplierSpecMapper wecSupplierSpecMapper;
    @Autowired(required = false)
    private MallProductSpecMapper mallProductSpecMapper;

    public WecSupplierSpecWithBLOBs getProductById(Long id) {
        return wecSupplierSpecMapper.selectByPrimaryKey(id);
    }


    public List<MallProductSpec> getSpecList(Integer startPage, Integer pageSize) {
        if (startPage == null || startPage <= 0) startPage = 1;
        if (pageSize == null || pageSize <= 0) pageSize = 10;

        Integer startIndex = (startPage - 1) * pageSize;

        return mallProductSpecMapper.getSpecList(startIndex,pageSize);
    }

    public Integer getCount() {
        return mallProductSpecMapper.getCount();
    }
}
